package com.ltkj.shop.controller;

import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.web.page.TableDataInfo;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.shop.domain.ShopHotelRoomType;
import com.ltkj.shop.service.IShopHotelRoomTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * 酒店房间类型Controller
 * 
 * @author xupf
 * @date 2023-10-07
 */
@Api(tags = "酒店房间类型")
@RestController
@RequestMapping("/roomType")
public class ShopHotelRoomTypeController extends BaseController
{
    @Autowired
    private IShopHotelRoomTypeService shopHotelRoomTypeService;

    /**
     * 查询酒店房间类型列表
     */
    @ApiOperation("查询酒店房间类型列表")
    @RequiresPermissions("shop:roomType:list")
    @GetMapping("/list")
    public TableDataInfo list(ShopHotelRoomType shopHotelRoomType)
    {
        if (null == shopHotelRoomType.getHotelId()) {
            return getDataTable(new ArrayList<>());
        }
        List<ShopHotelRoomType> list = shopHotelRoomTypeService.selectShopHotelRoomTypeList(shopHotelRoomType);
        return getDataTable(list);
    }

    /**
     * 导出酒店房间类型列表
     */
    @ApiOperation("导出酒店房间类型列表")
    @RequiresPermissions("shop:roomType:export")
    @Log(title = "酒店房间类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopHotelRoomType shopHotelRoomType)
    {
        List<ShopHotelRoomType> list = shopHotelRoomTypeService.selectShopHotelRoomTypeList(shopHotelRoomType);
        ExcelUtil<ShopHotelRoomType> util = new ExcelUtil<ShopHotelRoomType>(ShopHotelRoomType.class);
        util.exportExcel(response, list, "酒店房间类型数据");
    }

    /**
     * 获取酒店房间类型详细信息
     */
    @ApiOperation("获取酒店房间类型详细信息")
    @RequiresPermissions("shop:roomType:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopHotelRoomTypeService.selectShopHotelRoomTypeById(id));
    }

    /**
     * 新增酒店房间类型
     */
    @ApiOperation("新增酒店房间类型")
    @RequiresPermissions("shop:roomType:add")
    @Log(title = "酒店房间类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopHotelRoomType shopHotelRoomType)
    {
        return toAjax(shopHotelRoomTypeService.insertShopHotelRoomType(shopHotelRoomType));
    }

    /**
     * 修改酒店房间类型
     */
    @ApiOperation("修改酒店房间类型")
    @RequiresPermissions("shop:roomType:edit")
    @Log(title = "酒店房间类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopHotelRoomType shopHotelRoomType)
    {
        return toAjax(shopHotelRoomTypeService.updateShopHotelRoomType(shopHotelRoomType));
    }

    /**
     * 删除酒店房间类型
     */
    @ApiOperation("删除酒店房间类型")
    @RequiresPermissions("shop:roomType:remove")
    @Log(title = "酒店房间类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopHotelRoomTypeService.deleteShopHotelRoomTypeByIds(ids));
    }
}
